/**
 * 
 */
package lib.algo;

/**
 * 
 * @author <a href="www.sureinterview.com">SureInterview</a>
 */
abstract class FloodfillAbs<T> implements Floodfill<T> {
	T[][] space;
	T target, replace;
	int width, height;

	@Override
	public void fooldfill(T[][] space, int startx, int starty, T target,
			T replace) {

		if (space == null || target == null || replace == null)
			return;

		width = space.length;
		if (width == 0)
			return;

		height = space[0].length;
		if (height == 0)
			return;

		this.space = space;
		this.target = target;
		this.replace = replace;
		foolfill(startx, starty);
		return;
	}

	protected abstract void foolfill(int x, int y);
}
